<!-- 引入样式 -->
<script src="/assets/js/backend/vue/vue.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    {if condition="$store_id eq 0"}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('公司')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-store_id" data-rule="required" data-source="store/index" data-field="store_name" class="form-control selectpage" name="row[store_id]" type="text" value="{$row.store_id|htmlentities}">
        </div>
    </div>
    {/if}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Jianshe_company')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-jianshe_company" data-rule="required" class="form-control" name="row[jianshe_company]" type="text" value="{$row.jianshe_company|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Jianshe_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-jianshe_name" data-rule="required" class="form-control" name="row[jianshe_name]" type="text" value="{$row.jianshe_name|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Shigong_company')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-shigong_company" data-rule="required" class="form-control" name="row[shigong_company]" type="text" value="{$row.shigong_company|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Shigong_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-shigong_name" data-rule="required" class="form-control" name="row[shigong_name]" type="text" value="{$row.shigong_name|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Manager')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-manager" data-rule="required" class="form-control" name="row[manager]" type="text" value="{$row.manager|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Contact_tel')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-contact_tel" data-rule="required" class="form-control" name="row[contact_tel]" type="text" value="{$row.contact_tel|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="{$row.address|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Waste_type')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-waste_type" data-rule="required" class="form-control" name="row[waste_type]" type="text" value="{$row.waste_type|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Waste_count')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-waste_count" data-rule="required" class="form-control" name="row[waste_count]" type="text" value="{$row.waste_count|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Anti_pollution')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-anti_pollution" data-rule="required" class="form-control" name="row[anti_pollution]" type="text" value="{$row.anti_pollution|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Start_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-start_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" name="row[start_time]" type="text" value="{$row.start_time}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('End_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD"  name="row[end_time]" type="text" value="{$row.end_time}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Disposal_sites')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-disposal_sites" data-rule="required" class="form-control" name="row[disposal_sites]" type="text" value="{$row.disposal_sites|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Routes')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-routes" data-rule="required" class="form-control " rows="5" name="row[routes]" cols="50">{$row.routes|htmlentities}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Car_ids')}:</label>
        <div class="col-xs-12 col-sm-10">
            <input type="hidden" id="ids" name="row[car_ids]" value="{$row.car_ids|htmlentities}">
            <!-- <input id="c-car_ids" data-rule="required" data-source="car/index" data-multiple="true" class="form-control selectpage" name="row[car_ids]" type="text" value="{$row.car_ids|htmlentities}"> -->
            <template>
                <el-transfer
                  filterable
                  :filter-method="filterMethod"
                  :titles="['全部车辆', '已选车辆']"
                  @change="handleChange"
                  filter-placeholder="请输入车牌号搜索"
                  v-model="value"
                  :data="data">
                </el-transfer>
              </template>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
        <div class="col-xs-12 col-sm-8">
            <!-- <div class="input-group">
                <input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-images"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-images"></ul> -->
            <ul class="row list-inline faupload-preview" id="p-content_images">
                {volist name="$row['imagelist']" id="imagelist"}
                <li class="col-xs-3"><a href="{$imagelist|htmlentities}" data-url="{$imagelist|htmlentities}" target="_blank" class="thumbnail"><img src="{$imagelist|htmlentities}" onerror="this.src='{$imagelist|htmlentities}';this.onerror=null;" class="img-responsive"></a></li>
                {/volist}
            </ul>
        </div>
    </div>
    <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Add_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-add_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[add_time]" type="text" value="{:$row.add_time?datetime($row.add_time):''}">
        </div>
    </div> -->
    {if condition="$row['status'] eq 2 and $store_id eq 0"}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-status" class="form-control selectpicker"  name="row[status]">
                <option value="1">通过</option>
                <option value="4">拒绝</option>
            </select>

        </div>
    </div>
    {/if}
   

    {if condition="$row['status'] eq 4 or $row['status'] eq 5"}
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">审核状态:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-remark" readonly class="form-control"  type="text" value="未通过">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-remark" readonly class="form-control"  type="text" value="{$row.remark|htmlentities}">
        </div>
    </div>
    {/if}
    <div class="form-group" style="display: none;" id="remark">
        <label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-remark" data-rule="required" class="form-control" name="row[remark]" type="text" value="{$row.remark|htmlentities}">
        </div>
    </div>
    <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Authen_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-authen_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[authen_time]" type="text" value="{:$row.authen_time?datetime($row.authen_time):''}">
        </div>
    </div> -->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Is_del')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-is_del" class="form-control selectpicker" name="row[is_del]">
                {foreach name="isDelList" item="vo"}
                    <option value="{$key}" {in name="key" value="$row.is_del"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>
    {if condition="$store_id gt 0"}
    <div class="form-group" >
        <label class="control-label col-xs-12 col-sm-2">{:__('修改说明')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-change_title" data-rule="required" class="form-control" name="row[change_title]" type="text" style="height: 100px;"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('补充图片')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-change_images"  class="form-control" size="50" name="row[change_images]" type="text" value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-change_images" class="btn btn-danger faupload" data-input-id="c-change_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-change_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-change_images" class="btn btn-primary fachoose" data-input-id="c-change_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-change_images"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-change_images"></ul>
            
        </div>
    </div>
    {else/}
    {if !empty($change_info)}
    <div class="form-group" >
        <label class="control-label col-xs-12 col-sm-2">{:__('修改说明')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-change_title" readonly  class="form-control" type="text" style="height: 100px;">{$change_info.change_title|htmlentities}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('补充图片')}:</label>
        <div class="col-xs-12 col-sm-8">
            <!-- <div class="input-group">
                <input id="c-change_images" data-rule="required" class="form-control" size="50" type="text" value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-change_images" class="btn btn-danger faupload" data-input-id="c-change_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-change_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-change_images" class="btn btn-primary fachoose" data-input-id="c-change_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-change_images"></span>
            </div> -->
            <ul class="row list-inline faupload-preview" id="p-change_images">
                {volist name="$change_images" id="change_images"}
                <li class="col-xs-3"><a href="{$change_images|htmlentities}" data-url="{$change_images|htmlentities}" target="_blank" class="thumbnail"><img src="{$change_images|htmlentities}" onerror="this.src='{$change_images|htmlentities}';this.onerror=null;" class="img-responsive"></a></li>
                {/volist}
            </ul>
            
        </div>
    </div>
    {/if}
    {/if}
    
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    new Vue({
        el: '#edit-form',
        data: function() {
            const generateData = _ => {
                    const data = [];
                    const cities = ['上海', '北京', '广州', '深圳', '南京', '西安', '成都'];
                    const pinyin = ['shanghai', 'beijing', 'guangzhou', 'shenzhen', 'nanjing', 'xian', 'chengdu'];
                    cities.forEach((city, index) => {
                        data.push({
                        label: city,
                        key: index,
                        pinyin: pinyin[index]
                        });
                    });
                    return data;
                };
                return {
                    data: generateData(),
                    value: [],
                    filterMethod(query, item) {
                        return item.label.indexOf(query) > -1;
                    }
                };
            
        },

        created () {
            var that = this;
            var arr = [];
            var selectarr = [];
            var product_id='<?php echo $row['id'];?>'

            axios.post('/fQlTgiAVKu.php/product/getcar', {
               product_id:product_id
            })
            .then(function (response) {
                var datas = response.data.carlist;
                datas.forEach((res,index) =>{
                    arr.push({key:index,label:res.plate_number,pinyin:res.id})
                    if(res.ischeck==1)
                    {
                        selectarr.push(index)
                    }
                })
                
                that.data = arr;
                that.value = selectarr;
            })
            .catch(function (error) {
                console.log(error);
            });
        },
        methods:{
            handleChange(value, direction, movedKeys) {
                console.log(value);
                ids=[];
                value.forEach((city, index) => {
                    ids.push(
                        this.data[city].pinyin
                    );
                });
                console.log(ids);
                idstr=ids.join();
                $("#ids").val(idstr);
                // console.log(this.data[0].pinyin);
            }

        }
    })
</script>